package cn.com.miao.lynx.service.system.service.impl;

import cn.com.miao.lynx.common.base.mapping.BaseMapStructMapping;
import cn.com.miao.lynx.common.base.repository.BaseRepository;
import cn.com.miao.lynx.common.log.api.LogDetail;
import cn.com.miao.lynx.common.log.api.RemoteLogService;
import cn.com.miao.lynx.service.system.entity.SysLog;
import cn.com.miao.lynx.service.system.mapping.SysLogMapping;
import cn.com.miao.lynx.service.system.repository.SysLogRepository;
import cn.com.miao.lynx.service.system.service.SysLogService;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * SysLogServiceImpl
 *
 * @title: SysLogServiceImpl
 * @description:
 * @author: dengmiao
 * @create: 2019-12-27 12:51
 **/
@Slf4j
@Data
@AllArgsConstructor
@Service
public class SysLogServiceImpl implements SysLogService, RemoteLogService {

    private final SysLogRepository sysLogRepository;

    private final SysLogMapping sysLogMapping;

    @Override
    public BaseRepository<SysLog, Long> getRepository() {
        return this.getSysLogRepository();
    }

    @Override
    public BaseMapStructMapping<SysLog, Long> getMapStructMapping() {
        return this.getSysLogMapping();
    }

    @Override
    public void save(LogDetail logDetail) {
        SysLog sysLog = sysLogMapping.fromLogDetail(logDetail);
        sysLogRepository.save(sysLog);
    }
}
